//轮播图

let imglist=$("#imgbox li");
let ul=$("#imgbox");
let n=0;

function changeimg(){
    ul.animate({
        marginLeft:-(n*1920)
    })
}
//单击切换
$("#right").click(function(){
    if(n<imglist.length-1){
        n++;
    }
    else{
        n=0;
    }
    changeimg()
})
//登录页面展出
        var left = document.getElementById("left");
        var box1 = document.getElementById("box1");
        var box2 = document.getElementById("box2");
        var close = document.getElementById("close");
        var cang=document.getElementById("cang");
    left.onclick=function(){
        var firsttime=setInterval(function(){
        var far1=parseInt(box1.style.width);
        if(far1>400){
            clearInterval(firsttime)
            box1.style.width = "400px";
            var twotime=setInterval(function(){
                var far2=parseInt(box2.style.height);
                if(far2>500){
                    clearInterval(twotime)
                    box2.style.height="500px"
                    cang.style.display="block";
                    return;
                }
                box2.style.height = far2 + 5 + "px"
            },1)
            return;
        }
        box1.style.width = far1 + 4 + "px"
    },1)
}

//登录按钮单击事件
  //点击登录按钮
  $(".denglu").click(function(){
              
    let http=new XMLHttpRequest();
    http.open("get",`http://127.0.0.1:8080/deng?username=${$("#username").val()}&userpass=${$("#userpass").val()}`);
    if (username === "") {
        alert("请输入用户名");
        return;
    }
    //判断密码是否填写
    if (userpass === "") {
        alert("请输入密码");
        return;
    }
    http.send();
    http.onreadystatechange=function(){
        if(http.readyState===4){
            if(http.responseText === "success"){
                //免登录
                if($(".check")[0].checked){
                    localStorage.setItem("username",JSON.stringify($("#username").val()));
                    
                    localStorage.setItem("password",JSON.stringify($("#userpass").val()));
                  
            }
            alert("登录成功")
            location.href = "http://127.0.0.1:8080/west-point/src/index.html";
        }
        else{
            alert("用户名或密码错误")
        }
        }
    }
})